package com.sesame.feign;


import com.sesame.defin.Response;
import com.sesame.defin.ResponseFactory;
import com.sesame.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


@FeignClient(name = FeignServiceTest.APP_NAME, fallback = FeignServiceTestHystrix.class)
//@FeignClient(name = FeignServiceTest.APP_NAME)
public interface FeignServiceTest {

    String APP_NAME = "nacos-discovery-server";

    @RequestMapping("/test/index")
    Response<User> test(
            @RequestParam("name") String name
            , @RequestParam("pwd") String pwd
    );

}
@Component
class FeignServiceTestHystrix implements FeignServiceTest {
    @Override
    public ApiResult<User> test(String name, String pwd) {
        return ResponseFactory.feignException("test");
    }
}
